<template>
  <el-form ref="formRef" :model="formModel" :rules="rules" label-width="130px" class="form" label-position="right" status-icon>
    <el-form-item label="数量:" prop="quantity" v-if="!isEdit">
      <el-input-number v-model="formModel.quantity" @change="handleChange" :min="1" :max="999" label="请输入数量"></el-input-number>
    </el-form-item>
    <el-form-item label="设备号:" v-if="isShow">
      <div class="f-col" style="margin-top: 9px">
        <span style="height: 25px; line-height: 25px" v-for="(item, index) in deviceData" :key="index">{{ item }}</span>
      </div>
    </el-form-item>
    <el-form-item label="设备名称:" prop="name" v-if="isEdit">
      <el-input v-model.trim="formModel.name" class="form-item" placeholder="请输入设备名称" clearable />
    </el-form-item>
    <el-form-item label="设备投放地址:" prop="address" v-if="isEdit">
      <el-input v-model.trim="formModel.address" class="form-item" placeholder="请输入设备投放地址" clearable />
    </el-form-item>
    <el-form-item label="状态:" prop="status" v-if="isEdit">
      <query-dict
        :dict-list="baseDeviceStatusList"
        filterable
        class="form-select"
        placeholder="请选择状态"
        :value.sync="formModel.status"
      ></query-dict>
    </el-form-item>
  </el-form>
</template>

<script>
// import CUpload from 'components/upload'
import dictObj from '@/store/dictData'
import MixinForm from 'mixins/form'
// import utils from 'utils'

export default {
  mixins: [MixinForm],
  components: {
    // CUpload
  },
  props: {
    initData: {
      type: Object,
      default() {
        return {}
      }
    },
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      baseDeviceStatusList: dictObj.baseDeviceStatusList,
      rules: {
        quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }]
      },
      isShow: false,
      deviceData: []
    }
  },
  computed: {
    formModel: {
      get() {
        return this.initData
      },
      set(val) {
        this.$emit('update:init-data', val)
      }
    }
  },
  created() {
    console.log('67====', this.initData)
  },
  methods: {
    handleChange() {},
    changeShow(e, data) {
      this.isShow = e
      this.deviceData = data
    }
  }
}
</script>

<style lang="less" scoped>
.form {
  margin-right: 50px;
  .form-item {
    width: 100%;
  }
  .form-select {
    width: 50%;
  }
  .pic {
    padding-bottom: 25px;
    span {
      display: inline-block;
      margin-bottom: 10px;
    }
    .info {
      height: 20px;
      margin-top: 5px;
      font-size: @f12;
      line-height: 20px;
    }
  }
}
</style>
